<!DOCTYPE html>
<html>
<head>
    <title>管理员列表 - 后台管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" type="text/css" href="/static/layui/css/layui.css" media="all">
    <script type="text/javascript" src="/static/layui/layui.js"></script>
    <style type="text/css">
        .header span{background:#009688;margin-left:30px;padding:10px;color:#ffffff;}
        .header div{border-bottom:solid 2px #009688;margin-top: 8px;}
        .header button{float:right;margin-top:-5px;}
    </style>
</head>
<body style="padding:10px; box-sizing: border-box;">
<div class="header">
    <span>导航列表</span>
    <button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="add()">
        <i class="layui-icon layui-icon-add-1">添加</i>
    </button>
    <div></div>
</div>
<table class="layui-table">
    <thead>
    <tr>
        <th>ID</th>
        <th>菜单名</th>
        <th>排序</th>
        <th>状态</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    {foreach($lists as $lists_v)}
    <tr>
        <td>{$lists_v.menu_id}</td>
        <td>{$lists_v.label}</td>
        <td>{$lists_v.sort}</td>
        <td>
            {if($lists_v.status == 1)}
                开启
            {else}
                关闭
            {/if}
        </td>
        <td>
            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="button({$lists_v.menu_id})">
                <i class="layui-icon layui-icon-edit">下一级</i>
            </button>
            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="edit({$lists_v.menu_id})">
                <i class="layui-icon layui-icon-edit">修改</i>
            </button>
            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="del({$lists_v.menu_id})">
                <i class="layui-icon layui-icon-delete">删除</i>
            </button>
        </td>
    </tr>
    {/foreach}
    </tbody>
</table>
</body>
</html>
<script type="text/javascript">
    layui.use(['layer'],function(){
        $ = layui.jquery;
    });

    function add(){
        layer.open({
            type:2,
            title:'添加导航',
            shade:0.3,
            area:['550px','550px'],
            content:'/bew/menuadd'
        });
    }

    function edit(menu_id){
        layer.open({
            type:2,
            title:'编辑导航',
            shade:0.3,
            area:['550px','550px'],
            content:'/bew/menuedit?menu_id='+menu_id
        });
    }

    function del(menu_id){
        //删除提示
        layer.confirm("确定要删除吗?",{icon:3,btn:['确定','取消']},function(){
            $.get("/bew/menudel?menu_id="+menu_id,function(res){
                if(res.code == 0){
                    layer.msg(res.message,{'icon':1});
                    setTimeout(function(){
                        window.location.reload();
                    },1000);
                }else{
                    layer.msg(res.message,{'icon':2});
                }
            },'json');
        });
    }

    function button(menu_id){
        window.location.href = '/bew/buttonInfo?menu_id='+menu_id;

    }


</script>